/*********************************************************************
* File: Finances.h
*
* Implements the finances API.
*********************************************************************/
#pragma once

#include "../../engine.h"
#include "../globals.h"
#include "../interfaces/IFinances.h"
using namespace agents::interfaces;
namespace agents{ class Agent; }

namespace agents{ namespace modules{
	/**
	* \brief Implements the finances API.
	* 
	* Supports money management and armory upgrade.
	*
	* \author Instituto Superior Tecnico de Lisboa, Portugal
	* \author Technical University of Lisbon, Portugal
	* 
	* \author Agentes Autonomos e Sistemas Multiagente
	* \author Autonomous Agents and Multiagent Systems
	* 
	* \version	1.0
	* \date		2006/2007
	**/
	class Finances: public IFinances{
	public:

		Finances(Agent &owner);
		~Finances();

		void newRound();
		
		//Sensors
		/**
		* \brief Gets the agent's amount of money.
		*
		* \see agents::interfaces::IFinances::money
		**/
		int money(){ return _money; }
		/**
		* \brief Gets whether the agent is in the buy zone.
		*
		* \see agents::interfaces::IFinances::inBuyZone
		**/
		bool inBuyZone(){ return _inBuyZone; }
		bool withinBuyTime();

		//Actuators
		bool buy(char* name);
		bool buy(WeaponIds::Enumeration item);

		//Auxiliary
		/** 
		* \brief Sets the agent's money.
		**/
		void setMoney(int money){ _money=money; }
		/** 
		* Sets whether the agent is in the buy zone.
		**/
		void setInBuyZone(bool inBuyZone){ _inBuyZone=inBuyZone; }

	protected:
		bool buyCounterTerrorist(WeaponIds::Enumeration item);
		bool buyTerrorist(WeaponIds::Enumeration item);

		/** 
		* \brief The agent 
		**/
		Agent &_owner;

	private:
		/** 
		* \brief Whether agent is in the buy zone.
		**/
		bool _inBuyZone;
		/**
		* \brief The agent's money 
		**/
		int _money;
	};
}}

